/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skyproc;

import java.util.ArrayList;
import java.util.Objects;

/**
 *
 * @author Justin Swanson
 */
public class OTFT extends MajorRecord {

    static Type[] types = { Type.OTFT };

    SubFormArray INAM = new SubFormArray(Type.INAM, 0);

    OTFT() {
	super();
	subRecords.add(INAM);
    }

    public OTFT(Mod modToOriginateFrom, String uniqueEDID) {
	super(modToOriginateFrom, uniqueEDID);
    }

    @Override
    Type[] getTypes() {
	return types;
    }

    @Override
    Record getNew() {
	return new OTFT();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final OTFT other = (OTFT) obj;
        if (!Objects.equals(this.INAM, other.INAM)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + Objects.hashCode(this.INAM);
        return hash;
    }
    
    @Override
    public MajorRecord merge(MajorRecord no, MajorRecord bo) {
        super.merge(no, bo);
        OTFT e = this;
        if (!(no == null && bo == null && (no instanceof OTFT) && (bo instanceof OTFT))) {
            final OTFT ne = (OTFT) no;
            final OTFT be = (OTFT) bo;
            SubRecords sList = e.subRecords;
            SubRecords nsList = ne.subRecords;
            SubRecords bsList = be.subRecords;
            for (SubRecord s : sList) {
                s.merge(nsList.get(s.type[0]), bsList.get(s.type[0]));
            }
        }
        return e;
    }

    public ArrayList<FormID> getInventoryList() {
	return new ArrayList<>(INAM.IDs);
    }

    public void addInventoryItem(FormID item) {
	INAM.add(item);
    }

    public void removeInventoryItem (FormID item) {
	INAM.remove(item);
    }

    public void clearInventoryItems() {
	INAM.clear();
    }
}
